package com.mingqijia.gassafety.console.controller;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.webserver.request.MaintainLogAddRequest;
import com.mingqijia.gassafety.webserver.request.MaintainLogRequest;
import com.mingqijia.gassafety.webserver.response.AlertLogResponse;
import com.mingqijia.gassafety.webserver.response.MaintainLogResponse;
import com.mingqijia.gassafety.webserver.service.MaintainlogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 维保记录
 *
 * @author guoliang.lao
 * @since 2022-07-04
 */

@Slf4j
@Api(tags = "维护记录")
@RestController(value = "MaintainLogController")
@RequestMapping("/business/v1/maintainLog")
public class MaintainLogController {
    @Autowired
    MaintainlogService maintainlogService;

    @ApiOperation("维护记录新增")
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public CommonResponse<PageUtil<AlertLogResponse>> alert(@RequestBody MaintainLogAddRequest req){
        maintainlogService.add(req);
        return CommonResponse.success(null);
    }


    @ApiOperation("维护记录列表")
    @RequestMapping(value = "getLogsByConsumerId", method = RequestMethod.POST)
    public CommonResponse<PageUtil<MaintainLogResponse>> broken(@RequestBody MaintainLogRequest req){
        return CommonResponse.success(maintainlogService.maintainList(req));
    }

}

